1 : <?php
2 : /*--------------------------------------------------------------------------+
3 : This file is part of eStudy.
4 : news/classes/class.NewsCategoryAnnouncements.inc.php
5 : - Modulgruppe: News
6 : - Beschreibung: Klasse für die News-Kategorie Announcements.
7 : - Version: 1.1.2.4, 24/01/08
8 : - Autor(en): Corinna Kropf <corinna.kropf@mni.fh-giessen.de>
9 : +---------------------------------------------------------------------------+
10 : This program is free software; you can redistribute it and/or
11 : modify it under the terms of the GNU General Public License
12 : as published by the Free Software Foundation; either version 2
13 : of the License, or any later version.
14 : +---------------------------------------------------------------------------+
15 : This program is distributed in the hope that it will be useful,
16 : but WITHOUT ANY WARRANTY; without even the implied warranty of
17 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 : GNU General Public License for more details.
19 : You should have received a copy of the GNU General Public License
20 : along with this program; if not, write to the Free Software
21 : Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 : +--------------------------------------------------------------------------*/
23 :
24 1 : require_once ("class.newscategory.inc.php");
25 :
26 : /**
27 : * Klasse für die News-Kategorie Announcements.
28 : * @package eStudy.News
29 : * @version 1.1.2.4, 24/01/08
30 : * @author Corinna Kropf <corinna.kropf@mni.fh-giessen.de>
31 : */
32 1 : class NewsCategoryAnnouncements extends NewsCategory
33 : {
34 : /**
35 : * HTML-Template
36 : * @var Template
37 : */
38 : private $newsTemplate;
39 :
40 : /**
41 : * Cache Objekt zur Abfrage von Modulinstallationen (Performance Tweak)
42 : * @var array
43 : */
44 : private $installCacheObject;
45 :
46 : /**
47 : * Konstruktor
48 : */
49 : public function __construct($catID, $courses, $categorySettings = null, $cacheObject = null)
50 : {
51 0 : parent::__construct($catID, $courses, $categorySettings);
52 0 : $this->installCacheObject = $cacheObject;
53 0 : $this->newsTemplate = new Template(PATH_TO_ROOT."news/templates/newsannouncement.html");
54 0 : }
55 : /**
56 : * Muss angepasst werden, falls Modulgruppen umbenannt werden!
57 : * @see NewsCategory
58 : */
59 : public function isInstalled($courseID)
60 : {
61 0 : return Utilities::isInstalled("announcements", $courseID, $this->installCacheObject);
62 : }
63 : /**
64 : * @see NewsCategory
65 : */
66 : public function canSelectPeriod() {
67 0 : return true;
68 : }
69 : /**
70 : * @see NewsCategory
71 : */
72 : public function getNewsHeaderTitle($courseID = null, $type = null) {
73 0 : if(isset($this->news))
74 0 : {
75 0 : $newsCount = $this->news["count"];
76 0 : if ($newsCount > 1) $title = sprintf( $this->translate->_("%1\$s Mitteilungen"), $newsCount);
77 0 : elseif ($newsCount == 1) $title = $this->translate->_("1 Mitteilung");
78 0 : }
79 0 : else $title = $this->translate->_("Keine neuen Mitteilungen");
80 :
81 0 : return $title;
82 : }
83 :
84 : /**
85 : * @see NewsCategory
86 : */
87 : protected function getNewsByPeriod($courseID, $from, $to, $lastvisit, $usergroup = null) {
88 : // Neue Mitteilungen
89 0 : if (isset($courseID) && isset($from) && isset($to) && isset($this->coursePreferences))
90 0 : {
91 0 : if(!is_numeric($courseID) || !is_numeric($from) || !is_numeric($to) || !is_numeric($usergroup)) return null;
92 :
93 0 : global $db;
94 0 : $this->news = array();
95 :
96 0 : $timefrom = Data::toMysql($this->getPeriod($courseID, $from));
97 0 : $timeto = Data::toMysql($to);
98 :
99 : $sql = "SELECT * FROM announcements "
100 0 : ."WHERE course_id='".Data::toMysql($courseID)."' "
101 0 : ."AND date_display_from BETWEEN $timefrom "
102 0 : ."AND $timeto "
103 0 : ."ORDER BY date_display_from DESC";
104 0 : $this->news["data"] = $db->get_results($sql, ARRAY_A);
105 0 : $this->news["count"] = $db->num_rows;
106 0 : if ($db->num_rows > 0) $this->news["count"] = $db->num_rows;
107 0 : else $this->news = null;
108 0 : }
109 :
110 0 : return $this->news;
111 : }
112 : /**
113 : * @see NewsCategory
114 : */
115 : protected function echoNewsEntry($entry, $courseID, $usergroup = null)
116 : {
117 0 : if(!isset($entry) || !isset($courseID)) return;
118 :
119 0 : $link = PATH_TO_ROOT."announcement/announcement.php?show=all";
120 : // aus dem Foyer in einen Kurs
121 0 : if ($courseID && $courseID != $_SESSION["course"]) $link .= "&changeToCourse=$courseID";
122 0 : $announcementTitle = Data::toHTML($entry["title"]);
123 0 : $announcementText = Data::toHTML(Utilities::chopText($entry["text"]));
124 :
125 0 : $g_zurMitteilungsseite = $this->translate->_("zur Mitteilungsseite");
126 0 : $g_Lesen = $this->translate->_("lesen");
127 :
128 0 : eval($this->newsTemplate->GetTemplate());
129 0 : }
130 : }
|